Trabb Pardo–Knuth algorithm